﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace WpfApp16
{
    public class ValueTemplateSelector : DataTemplateSelector
    {
        public DataTemplate IntTemplate { get; set; }
        public DataTemplate FloatTemplate { get; set; }
        public DataTemplate DoubleTemplate { get; set; }
        public DataTemplate BoolTemplate { get; set; }
        public DataTemplate TextTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is EnumDataType enumType)
            {
                switch (item)
                {
                    case EnumDataType.Integer:
                        return IntTemplate;
                    case EnumDataType.Float:
                        return FloatTemplate;
                    case EnumDataType.Double:
                        return DoubleTemplate;
                    case EnumDataType.String:
                        return TextTemplate;
                    case EnumDataType.Boolean:
                        return BoolTemplate;
                }
            }
            return base.SelectTemplate(item, container);
        }
    }
}
